package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.MatBom;
import com.indusfo.spc.service.MatBomService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/22 13:58
 * @Version 1.0
 */
@Controller
@RequestMapping(value = "/service/matBom")
public class MatBomController {

    @Autowired
    private MatBomService matBomService;

    //查询
    @RequestMapping(value = "/queryMatBom")
    @ResponseBody
    public JSONObject queryMatBom(MatBom matBom) {
        JSONObject json = matBomService.queryMatBom(matBom);
        return json;
    }

    //新增
    @RequestMapping(value = "/insertMatBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertMatBom(MatBom matBom) {
        JSONObject json = matBomService.insertMatBom(matBom);
        return json;
    }

    //修改
    @RequestMapping(value = "/updateMatBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateMatBom(MatBom matBom) {
        JSONObject json = matBomService.updateMatBom(matBom);
        return json;
    }

    //删除
    @RequestMapping(value = "/deleteMatBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteMatBom(@RequestParam("matBomIds") List<Integer> matBomIds, Integer dataState) {
        dataState = 2;
        JSONObject json = matBomService.deleteMatBom(matBomIds, dataState);
        return json;
    }


    //启用/停用
    @RequestMapping(value = "/definedMatBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedMatBom(@RequestParam("matBomIds") List<Integer> matBomIds, Integer dataState) {
        JSONObject json = matBomService.deleteMatBom(matBomIds, dataState);
        return json;
    }
}
